package com.zhang.producer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Package: com.zhang.producer
 * @ClassName: StreamBridgeProducer
 * @Author: Think
 * @CreateTime: 2021/7/19 10:49
 * @Description:
 */
@Slf4j
@Service
public class StreamBridgeProducer {

    @Autowired
    private StreamBridge streamBridge;

    public void sendDateMessage(){
        Message<Date> message = MessageBuilder.withPayload(new Date()).build();
        log.info("开始发送消息！");
        streamBridge.send("mySource-out-1", message);
    }

}
